﻿using System;
using System.Runtime.Serialization;

using zijian666.Converts.Abstractions;

namespace zijian666.Converts.Translator;

/// <summary>
/// <seealso cref="IObjectReference"/> 翻译器
/// </summary>
public class ObjectReferenceTranslator : ITranslator
{
    /// <inheritdoc />
    public bool CanTranslate(Type type)
        => typeof(IObjectReference).IsAssignableFrom(type);

    /// <inheritdoc />
    public object? Translate(IConvertContext context, object input)
        => ((IObjectReference)input).GetRealObject(default);
}
